package com.lagou.dao;

import com.lagou.util.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import java.sql.SQLException;


/**
 * 登陆dao层
 */
public class LoginDao {
    public static long checkLogin(String userName,String passWord) throws SQLException{
        //创建工具类
        QueryRunner qr = new QueryRunner(DruidUtils.getDataSource());
        //查询改账号密码在数据库中的记录数
        String sql = "select count(1) as numb from user where username = ? and password = ?";
        //设置查询参数为账号密码
        Object[] param = {userName,passWord};
        //接收返回的数量并且返回
        Long query = (Long)qr.query(sql, new ScalarHandler(), param);
        return query;
    }

}
